//
//  SceneDelegate.swift
//  Kosspot
//
//  Created by 李鑫 on 2025/8/25.
//


import UIKit
import SwiftUI


class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
           URLContexts.forEach { context in
               let url = context.url
               if url.scheme?.hasPrefix("wx") == true {
                   WXApi.handleOpen(url, delegate: WeChatManager.shared)
               }
           }
       }
    func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
           guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
                 let url = userActivity.webpageURL else { return }
           WXApi.handleOpenUniversalLink(userActivity, delegate:WeChatManager.shared)
       }
}


/*
extension SceneDelegate: WXApiDelegate {
    func onResp(_ resp: BaseResp) {
        if let authResp = resp as? SendAuthResp {
            DispatchQueue.main.async {
                if authResp.errCode == 0 {
                    print("授权成功 code: \(authResp.code ?? "")")
                } else {
                    print("授权失败: \(authResp.errStr ?? "未知错误")")
                }
            }
        }
    }
}  */
